<template>
	<view class="content-box">
		<view class="content-box-top-px">
			<view class="t1">
				<view class="t2">
					<view class="t3">
						练习记录
					</view>
					<view class="t4">
						记录职工的练习情况
					</view>
				</view>
				<image src="../../static/training/lxjl.png" class="img" mode="widthFix"></image>
				<!-- <view class="t5">
					<view class="t6">全部</view>
					<view class="se"></view>
				</view> -->
				<view class="t5">
					<view class="def">题库练习</view> 
					<view class="se"></view>
				</view>
				<!-- <view class="t5">
					<view class="def">题库练习</view> 
				</view>
				<view class="t5">
					<view class="def">知识点练习</view> 
				</view>
				<view class="t5">
					<view class="def">签到每日一练</view> 
				</view> --> 
			</view>
		</view>
		<view class="back_btn_box">
			<image src="../../static/training/back.png" style="width: 20rpx;" mode="widthFix" @click="back"></image>
		</view>
		<view class="share_btn_box">
			<image src="../../static/px/search.png" style="width: 40rpx;" mode="widthFix"></image>
		</view>
		<view class="lx_item" v-for="(item,index) in dataList" :key="index" @click="detail(item)">
			<view class="t1">
				<view class="lable lable_c1">
					题库练习
				</view>
			</view>
			<view class="t2">
				{{item.examName}}
			</view>
			<view class="t3">
				{{item.examStartTime}}~{{item.examEndTime}}
			</view>
			<view class="t3">
				<view class="t_lable tl1">
					<view style="background: #F93B4A;color: white;float: left;margin-left: -10rpx;width: 50rpx;text-align: center;">分数</view>
					<view style="float: left;margin-left: 10rpx;">{{item.score}}分</view>
				</view>
				<view class="t_lable tl2">
					{{item.seconds}}
				</view>
			</view> 
		</view>
		<!-- <view class="lx_item" @click="detail">
			<view class="t1">
				<view class="lable lable_c2">
					知识点练习
				</view>
			</view>
			<view class="t2">
				知识点知识点知识点
			</view>
			<view class="t3">
				2023-02-08-2023-04-08
			</view>
			<view class="t3">
				<view class="t_lable tl1">
					<view style="background: #F93B4A;color: white;float: left;margin-left: -10rpx;width: 50rpx;text-align: center;">分数</view>
					<view style="float: left;">89分</view>
				</view>
				<view class="t_lable tl2">
					34"34'
				</view>
			</view> 
		</view> --> 
		<view class="magin_top20"></view>  
	</view>

</template>

<script>
	import {
		myPracticeRecords
	} from "@/common/api/training/training.js";
	export default {
		data() {
			return {
				dataList:[] 
			};
		},
		onLoad() {
			this.getList(); 
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			course(){
				uni.navigateTo({
					url:"/pages/training/course"
				})
			},
			topic(){
				uni.navigateTo({
					url:"/pages/training/topic"
				})
			},
			detail(item){
				uni.navigateTo({
					url: '/pages/training/practiceDetail?id='+item.id+"&examName="+item.examName
				});
			},
			getList(){
				myPracticeRecords({
					 "pageNum": 1,
					 "pageSize": 99,
					 "query": {
					  }
					}).then((res) => {
					if (res && res.code == 200 && res.data) {
						for(var i=0;i<res.data.rows.length;i++){
							if(res.data.rows[i].seconds){
								res.data.rows[i].seconds=this.timeStr(res.data.rows[i].seconds)
								//console.log(res.data.rows[i].seconds)
							}
							if(res.data.rows[i].examEndTime){
								res.data.rows[i].examEndTime=res.data.rows[i].examEndTime.substring(0,10)
							}
							if(res.data.rows[i].examStartTime){
								res.data.rows[i].examStartTime=res.data.rows[i].examStartTime.substring(0,10)
							}
						}
						this.dataList=res.data.rows; 
					}
				}); 
			},
			timeStr(seconds) {
			    // 转为对应的   分, 秒 
			    let m = parseInt(seconds / 60 % 60)
			    let s = parseInt(seconds % 60)
			    // 自动补零 
			    m = m > 10 ? m : '0' + m;
			    s = s > 10 ? s : '0' + s;
			    // 拼接字符串
			    let timestr = `${m}"${s}'`;
			    // 将字符串返回
			    return timestr;
			} 
		},
	};
</script>

<style lang="scss" scoped>
	@import url("../../common/base.css");
	@import "./info.scss";

	page {
		background-color: #F2F3F6;
	}
</style>